<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        .parent{
            position: relative;
            width: 800px;
            height: 200px;
            background-color: gold;
        }
        .child{
            position: absolute;
            /* 50%是指父宽度的50% */
            left: 50%;
            height: 200px;
            background-color: skyblue;
            /* 50%是指父宽度的50% 不行 */
            /* margin-left: -50%; */

            /* -50% 是子宽度的50% */
            transform: translateX(-50%);
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child">123456789</div>
    </div>
</body>
</html>